<?php
	require_once (dirname(__FILE__)."/../config/api.inc");
	require_once (dirname(__FILE__)."/../config/Config.inc");
	
	$result['status'] = '0';
	
	$parm = requestArrayParm($_REQUEST);
	
	if(!empty($parm['id']))
	{
		unset($wheres);
		$wheres['id'] = $parm['id'];
		$wheres['status'] = '2';
		$touzi = _SqlTool::getInfo('touzi', $wheres);
		if(!empty($touzi))
		{
			unset($temp);
			$temp['chanpin_id'] = $touzi['id'];
			$temp['tongji_type'] = 'touzi';
			add_tongji($userinfo,$temp);

            unset($temp);
			$temp['id'] = $touzi['id'];
			$temp['title'] = $touzi['title'];
			$temp['title2'] = $touzi['desc'];
			$temp['auther'] = $touzi['auther'];
			$temp['addtime'] = date('Y-m-d H:i',$touzi['addtime']);
			
			if(!empty($touzi['fengmian']))
			{
				$temp['fengmian'] = OSS_URL. $touzi['fengmian'];
			}
			
			if(!empty($touzi['img']))
			{
				$temp['img'] = OSS_URL. $touzi['img'];
			}
			
			if(!empty($touzi['video']))
			{
				$temp['video'] = OSS_URL. $touzi['video'];
			}
			
			if(!empty($touzi['audio']))
			{
				$temp['audio'] = OSS_URL. $touzi['audio'];
			}
			
			$temp['content'] = $touzi['content'];
			
			$result['status'] = '1';
			$result['info'] = $temp;
		}
		else
		{
			$result['msg'] = '数据异常';
		}
	}
	else
	{
		//查询投资攻略
		unset($wheres,$pages,$sorts,$list);
		$wheres['status'] = '2';
		$pages['rows'] = 20;
		$pages['page'] = getParam('page','request',1);
		$sorts['addtime'] = 'desc';
		$resData = _SqlTool::getList('touzi', $wheres,$pages,$sorts);

		foreach ($resData['list'] as $k => $touzi)
		{
			unset($temp);
			$temp['id'] = $touzi['id'];
			$temp['title'] = $touzi['title'];
			$temp['title2'] = $touzi['desc'];
			$temp['auther'] = $touzi['auther'];
			$temp['addtime'] = date('Y-m-d H:i',$touzi['addtime']);
			
			if(!empty($touzi['fengmian']))
			{
				$temp['fengmian'] = OSS_URL. $touzi['fengmian'];
			}
			
			if(!empty($touzi['img']))
			{
				$temp['img'] = OSS_URL. $touzi['img'];
			}
			
			if(!empty($touzi['video']))
			{
				$temp['video'] = OSS_URL. $touzi['video'];
			}
			
			if(!empty($touzi['audio']))
			{
				$temp['audio'] = OSS_URL. $touzi['audio'];
			}
			
			$temp['content'] = $touzi['content'];
			
			$list[] = $temp;
		}
		
		if($list)
		{
			$result['status'] = '1';
			$result['list'] = $list;
			$result['pages'] = $resData['pages'];
			
		}
	}
	
	echoJSON($result);